﻿using System;
using System.Collections.Generic;
using System.Text;

using MySql.Data.MySqlClient;

namespace Cisoft.EMA.DAL
{
    public class SMS_OutBox_DAL
    {
        public SMS_OutBox_DAL()
        {     
        }

        #region 添加短信发送数据 public int InsertRecord(Cisoft.EMA.Model.SMS_OutboxMO _smsoutbox)
        /// <summary>
        /// 添加短信发送数据
        /// Ryan 2009-4-13
        /// </summary>
        /// <param name="_smsoutbox"></param>
        public int InsertRecord(Cisoft.EMA.Model.SMS_OutBox _smsoutbox)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("Insert into sms_outbox(sismsid,extcode,destaddr,messagecontent,");
            strSql.Append("reqdeliveryreport,msgfmt,sendmethod,requesttime,applicationid,ecid) ");
            strSql.Append("values (?sismsid,?extcode,?destaddr,?messagecontent,");
            strSql.Append("?reqdeliveryreport,?msgfmt,?sendmethod,?requesttime,?applicationid,?ecid)");
            MySqlParameter[] parameters = new MySqlParameter[10];
            parameters[0] = new MySqlParameter("?sismsid", MySqlDbType.VarChar, 50);
            parameters[0].Value = System.Guid.NewGuid().ToString();
            parameters[1] = new MySqlParameter("?extcode", MySqlDbType.VarChar, 21);
            parameters[1].Value = _smsoutbox.Extcode;
            parameters[2] = new MySqlParameter("?destaddr", MySqlDbType.VarChar, 2000);
            parameters[2].Value = _smsoutbox.Destaddr;
            parameters[3] = new MySqlParameter("?messagecontent", MySqlDbType.VarChar, 2000);
            parameters[3].Value = _smsoutbox.Messagecontent;
            parameters[4] = new MySqlParameter("?reqdeliveryreport", MySqlDbType.Int32, 11);
            parameters[4].Value = _smsoutbox.Reqdeliveryreport;
            parameters[5] = new MySqlParameter("?msgfmt", MySqlDbType.Int32, 11);
            parameters[5].Value = _smsoutbox.Msgfmt;
            parameters[6] = new MySqlParameter("?sendmethod", MySqlDbType.Int32, 11);
            parameters[6].Value = _smsoutbox.Sendmethod;
            parameters[7] = new MySqlParameter("?requesttime", MySqlDbType.DateTime);
            parameters[7].Value = _smsoutbox.Requesttime;
            parameters[8] = new MySqlParameter("?applicationid", MySqlDbType.VarChar, 16);
            parameters[8].Value = _smsoutbox.Applicationid;
            parameters[9] = new MySqlParameter("?ecid", MySqlDbType.VarChar, 20);
            parameters[9].Value = _smsoutbox.ECID;

            return EMA.DataHelper.MySqlDBUtil.ExecuteInsert2(strSql.ToString(), parameters);
        }
        #endregion


        public DateTime GetSMSSendTime(Cisoft.EMA.Model.SMS_OutboxMO _smsoutbox)
        {
            return _smsoutbox.Requesttime;
        }
    }
}
